package com.example.common.redis;

import org.springframework.data.redis.core.RedisTemplate;

import javax.annotation.Resource;
import java.util.concurrent.TimeUnit;

/**
 * @Author wxy
 * @Date 2020/9/22 9:57
 * @Version 1.0
 */
public class RedisServiceImpl implements RedisService {
    @Resource
    private RedisTemplate<String, Object> redisTemplate;

    @Override
    public void setString(String tel,String phoneCode, int i) {
        redisTemplate.opsForValue().set(tel,phoneCode,i, TimeUnit.MINUTES);
    }

    @Override
    public String getString(String key) {
        return (String) redisTemplate.opsForValue().get(key);
    }
}
